package com.jsm.tf.net.handler;

import com.jsm.tf.net.session.ISessionManager;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@ChannelHandler.Sharable
@Component
public class IdleStateEventHandler extends ChannelDuplexHandler {
    @Resource
    private ISessionManager sessionManager;
    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof IdleStateEvent) {
            IdleStateEvent event = (IdleStateEvent) evt;
            if(event.state()== IdleState.READER_IDLE){
                log.info(" 已经很久读到该channel数据了:{}",ctx.channel());
            }

        }
    }
}
